<?
	include ('../defines.php');
	FunctionsHelper::includeFiles(
		array(
			ADMINISTRATOR_CONTROLLER_DIRECTORY . $_POST['controller'] . '.php'
		)
	);

	switch($_POST['controller']){
		case 'players':
			$players = new Players();
			if ($_POST['operation']=='delete')
				echo $players->deletePlayer($_POST['id']);
			else if ($_POST['operation']=='activate')
				echo $players->activatePlayer($_POST['id']);
			else if ($_POST['operation']=='getFromNation')
				echo $players->getPlayersFromNation($_POST['id']);
			else if ($_POST['operation']=='getFromNationAndSex')
				echo $players->getPlayersFromNationAndSex($_POST['id'], $_POST['sex']);
			break;
		case 'countries':
			$countries = new Countries();
			if ($_POST['operation']=='delete')
				echo $countries->deleteCountry($_POST['id']);
			else if ($_POST['operation']=='activate')
				echo $countries->activateCountry($_POST['id']);
			break;
		case 'users':
			$user = new Users();
			if ($_POST['operation']=='delete')
				echo $user->deleteUser($_POST['id']);
			else if ($_POST['operation']=='activate')
				echo $user->activateUser($_POST['id']);
			else if($_POST['operation'] == 'logout')
				echo $user->LogOut();
			break;
		case 'news':
			$news = new NewsC();
			if ($_POST['operation']=='delete')
				echo $news->deleteNews($_POST['id']);
			else if ($_POST['operation']=='activate')
				echo $news->activateNews($_POST['id']);
			else if ($_POST['operation']=='deleteImage')
				echo $news->deleteImage($_POST['id']);
			else if ($_POST['operation']=='modifyText')
				echo $news->modifyText($_POST['id'], $_POST['text'], $_POST['tag']);
			else if ($_POST['operation']=='deleteAudio')
				echo $news->deleteAudio($_POST['id']);
			else if ($_POST['operation']=='deleteVideo')
				echo $news->deleteVideo($_POST['id']);
			else if ($_POST['operation']=='deleteTag')
				echo $news->deleteTag($_POST['id']);
			else if ($_POST['operation']=='deleteResource')
				echo $news->deleteResource($_POST['id'], $_POST['resource-type']);
			else if ($_POST['operation']=='modifyResource')
				echo $news->modifyResource($_POST['id'], $_POST['resource-type'], array('text' => $_POST['text'], 'tag' => $_POST['tag']));
			break;
		case 'tournaments':
			$tournaments = new Tournaments();
			if ($_POST['operation']=='delete')
				echo $tournaments->deleteTournament($_POST['id']);
			else if ($_POST['operation']=='activate')
				echo $tournaments->activateTournament($_POST['id']);
			else if ($_POST['operation']=='deleteMatch')
				echo $tournaments->deleteMatch($_POST['id']);
			else if ($_POST['operation']=='deleteInternationalMatch')
				echo $tournaments->deleteInternationalMatch($_POST['id']);
			break;
		case 'surveys':
			$survey = new Surveys();
			if ($_POST['operation']=='deleteOption')
				echo $survey->deleteOption($_POST['id']);
			else if ($_POST['operation']=='addOption')
				echo $survey->createOption(array('survey_id' => $_POST['survey_id'], 'optionDescription' => $_POST['description']));
			else if ($_POST['operation']=='deleteSurvey')
				echo $survey->deactivateSurvey($_POST['id']);
			else if ($_POST['operation']=='activateSurvey')
				echo $survey->activateSurvey($_POST['id']);
			break;
		case 'matches':
			$matches = new Matches();
			if ($_POST['operation']=='insertInternationalMatches')
				echo $matches->insertInternationalMatch($_POST);
			else if ($_POST['operation']=='getAllFromSerie')
				echo $matches->getAllFromSerie($_POST['id']);				
			break;
	}
	
	
?>
